package com.example.yunxinagyue

import android.graphics.drawable.Drawable
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.graphics.drawable.toDrawable
import androidx.viewpager.widget.ViewPager

class RecommendFragment : Fragment() {

    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.fragment_recommend_fragement, container, false)
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        val looperImg= view.findViewById<ViewPager>(R.id.looper_img)

        val imgList= mutableListOf<Drawable>()
        imgList.add(R.drawable.looper_1.toDrawable())
        imgList.add(R.drawable.looper_2.toDrawable())
        imgList.add(R.drawable.looper_3.toDrawable())
        imgList.add(R.drawable.looper_4.toDrawable())
        val looperAdapter=LopperAdapter(imgList)
        looperImg.adapter=looperAdapter
    }

    companion object {
        fun newInstance() = RecommendFragment()
    }
}